#include <iostream>

using namespace std;
typedef long long LL;
int main()
{
	LL t; cin >> t;
	while (t--)
	{
		LL n; cin >> n;
		LL a, p; cin >> a >> p;
		a %= p;
		for (LL i = 3; i <= n; i++)
		{
			LL x; cin >> x;
			a = a * x % p;
		}
		if (a) cout << "No" << endl;
		else cout << "Yes" << endl;
	} 
	return 0;
}



